package com.yantong.service.impl;

import com.yantong.utils.PageUtils;
import com.yantong.pojo.MemberProductAuthority;
import com.yantong.mapper.MemberProductAuthorityMapper;
import com.yantong.service.MemberProductAuthorityService;
import org.apache.ibatis.session.RowBounds;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 请填写MemberProductAuthorityServiceImpl的描述
 *
 * @author huangshuai-728982210@qq.com
 * @date 2021/5/31 14:56
 */
@Service
public class MemberProductAuthorityServiceImpl implements MemberProductAuthorityService {

	@Autowired
	private MemberProductAuthorityMapper memberProductAuthorityMapper;


	@Override
	public PageUtils<MemberProductAuthority> selectAllByMember(Long mid,int offset, int limit) {
		PageUtils<MemberProductAuthority> pageUtils = new PageUtils<>();
		int total = memberProductAuthorityMapper.countByMid(mid);
		if (total > 0) {
			pageUtils.setTotal(total);
			pageUtils.setRows(memberProductAuthorityMapper.listByMid(mid,new RowBounds(offset, limit)));
		}
		return pageUtils;
	}

	@Override
	public List<MemberProductAuthority> selectMemberProductAuthorityListByProductAuthortyId(Long productAuthorityId) {

		return memberProductAuthorityMapper.selectMemberProductAuthorityListByProductAuthortyId(productAuthorityId);
	}

	@Override
	public int removeMemberProductAuthority(Long id) {

		return memberProductAuthorityMapper.deleteByPrimaryKey(id);
	}

}
